package com.jiot.controller.device;

import com.zg.cloud.BaseResponse;
import com.zg.cloud.service.InformationServer;
import com.zg.cloud.service.ProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import req.information.AddInformationReq;
import req.information.DeleteInformationReq;
import req.information.ModifyInformationReq;
import req.information.SetReleaseStatusReq;
import req.product.AddProductReq;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author hushi
 * @date 2020/10/20 16:30
 * @description
 */
@RestController
@RequestMapping("/device/industry/information")
@Api(value = "资讯模块")
public class InformationController {

    @Resource
    private InformationServer informationServer;

    @PostMapping("/add/information")
    @ApiOperation(value = "添加资讯", notes = "device")
    public BaseResponse addInformation(@RequestBody @Valid AddInformationReq addInformationReq) {
        informationServer.addInformation(addInformationReq);
        return new BaseResponse();
    }

    @PostMapping("/delete/information")
    @ApiOperation(value = "删除资讯", notes = "device")
    public BaseResponse deleteInformation(@RequestBody @Valid DeleteInformationReq deleteInformationReq) {
        informationServer.deleteInformation(deleteInformationReq);
        return new BaseResponse();
    }

    @PostMapping("/modify/information")
    @ApiOperation(value = "修改资讯", notes = "device")
    public BaseResponse modifyInformation(@RequestBody @Valid ModifyInformationReq modifyInformationReq) {
        informationServer.modifyInformation(modifyInformationReq);
        return new BaseResponse();
    }

    @PostMapping("/select/information/all")
    @ApiOperation(value = "查询资讯列表", notes = "device")
    public BaseResponse selectInformationAll() {
        BaseResponse baseResponse = new BaseResponse();
        baseResponse.setData(informationServer.selectInformationAll());
        return baseResponse;
    }

    @PostMapping("/set/release/status")
    @ApiOperation(value = "更改发布状态", notes = "device")
    public BaseResponse setReleaseStatus(@RequestBody @Valid SetReleaseStatusReq setReleaseStatusReq) {
        informationServer.setReleaseStatus(setReleaseStatusReq);
        return new BaseResponse();
    }
}
